﻿using FriendAnalyzer.Infrastructure.Facebook.Interfaces;
using FriendAnalyzer.Infrastructure.Facebook.Model;
using FriendAnalyzer.Infrastructure.Facebook.Model.Enums;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace FriendAnalyzer.Infrastructure.Facebook.Tests.Mocks
{
    public class MockFriendRepository : IFriendRepository
    {
        public async Task<List<FacebookEvent>> GetAllFriendEventsAsync()
        {
            return await RunAsync(GenerateEvents);
        }
        public async Task<List<FacebookLike>> GetAllPageLikesAsync()
        {
            return await RunAsync(GenerateLikes);
        }
        public async Task<List<FacebookUser>> GetFacebookFriendsAsync()
        {
            return await RunAsync(GenerateUsers);
        }
        public async Task<List<FacebookGroup>> GetAllGroupsAsync()
        {
            return await RunAsync(GenerateGroups);
        }
        public async Task<List<FacebookCheckin>> GetAllCheckinsAsync()
        {
            return await RunAsync(GenerateCheckins);
        }

        private async Task<List<T>> RunAsync<T>(Func<List<T>> generator)
        {
            return await Task.Factory.StartNew<List<T>>(generator);
        }

        public List<FacebookLike> GenerateLikes()
        {
            var list = new List<FacebookLike>();

            for (ulong i = 0; i <= 10; i++)
            {
                list.Add(new FacebookLike
                {
                    LikedBy = i,
                    LikedID = i,
                    LikeType = LikeType.Page,
                });
            }

            return list;
        }
        public List<FacebookUser> GenerateUsers()
        {
            var list = new List<FacebookUser>();

            for (ulong i = 0; i <= 10; i++)
            {
                list.Add(new FacebookUser
                {
                    UserID = i,
                    FirstName = "First",
                    LastName = "Last" + i,
                    PictureUrl = "PictureUrl",
                });
            }

            return list;
        }
        public List<FacebookEvent> GenerateEvents()
        {
            var list = new List<FacebookEvent>();

            for (ulong i = 0; i <= 10; i++)
            {
                list.Add(new FacebookEvent
                {
                    AttendedBy = i,
                    EventID = i,
                });
            }

            return list;
        }
        public List<FacebookGroup> GenerateGroups()
        {
            var list = new List<FacebookGroup>();

            for (ulong i = 0; i <= 10; i++)
            {
                list.Add(new FacebookGroup
                {
                    GroupID = i,
                    MemberID = i,
                });
            }

            return list;
        }
        public List<FacebookCheckin> GenerateCheckins()
        {
            var list = new List<FacebookCheckin>();

            for (ulong i = 0; i <= 10; i++)
            {
                list.Add(new FacebookCheckin
                {
                    LocationID = i,
                    UserID = i,
                });
            }

            return list;
        }
    }
}